package com.itheima.wordcount;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class WordCountReduceTask extends Reducer<Text, IntWritable,Text,IntWritable> {
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        //1、先获取key值
        String word = key.toString();

        int count=0;
        for(IntWritable v2:values){
            count+=v2.get();
        }

        //3、对累加的结果输出
        context.write(key,new IntWritable(count));
    }
}
